import random
import string
total_str=""
total_dict={}
with open("Walden.txt","r+",encoding="utf-8") as fp:
   for line in fp:
      for i in line:
         if i in string.ascii_letters or i==" ":
            total_str+=i.lower()
total_list=total_str.split(" ")
total_set=set(total_list)
for a in total_set:
    total=total_list.count(a)
    total_dict[a]=total
for x,y in total_dict.items():
   print(x,"出现了",y,"次")

